<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>格林农场</title>

      <!-- Bootstrap Core CSS -->
    <link href="/Green/Public/assest/css/bootstrap.min.css" rel="stylesheet">

    <!-- Custom CSS -->
    <link href="/Green/Public/assest/css/landing-page.css" rel="stylesheet">

    <!-- Custom Fonts -->
    <link href="/Green/Public/assest/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
    <link href="https://fonts.googleapis.com/css?family=Lato:300,400,700,300italic,400italic,700italic" rel="stylesheet" type="text/css">
	
	 <link href="/Green/Public/assets/css/bootstrap.min.css" rel="stylesheet">

    <!-- Custom styles for this template -->
    <link href="/Green/Public/assets/css/dashboard.css" rel="stylesheet">
	
	  <link href="http://libs.baidu.com/bootstrap/3.0.3/css/bootstrap.min.css" rel="stylesheet">
   <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
   <script src="http://libs.baidu.com/bootstrap/3.0.3/js/bootstrap.min.js"></script>
   <script src="/Green/Public/Js/jquery-3.1.1.slim.js"></script><!--jQuery-->
   <style>
    #pageButton{
			width:80%;
			margin-left:10%;
	   }
	   #left{
			width:50%;
			
	   }
	   #right{
			width:50%;
			margin-left:50%;
			
	   }
	   #top{
		width:100%;
		height:140px;
	   }
		#tleft{
			float:left;
			height:100px;
			margin-left:8%;
		}
		#tright{
			height:100%;
			height:100px;
			margin-left:200px;
		}
		#search{
			margin-top:30px;
			margin-left:40px;
			border-radius:2px;
			border:solid 3px green;
			width:450px;
			height:40px;
		}
		#btn{
			border-radius:5px;
			background-color:grey;
			color:white;
			height:40px;
			width:100px;
		}
	</style>
	<script>
	 	var istrue=false;
		function test(){
			var s1=document.getElementById("pwd").value;
			var s2=document.getElementById("rpwd").value;
			var s3 =document.getElementById("clogodiv");
			if(s1!=s2){
			s3.innerHTML="错误";
			alert("两次密码输入不一致！");
			s3.style.color="red";
			istrue=false;
			}else if(s1!="" && s1==s2){
			 s3.style.color="blue";
			  s3.innerHTML="正确";
			  istrue=true;
			}
		}
		//设置Cookie
		function setCookie(c_name,value,expiredays)
		{
		var exdate=new Date()
		exdate.setDate(exdate.getDate()+expiredays)
		document.cookie=c_name+ "=" +escape(value)+
		((expiredays==null) ? "" : "; expires="+exdate.toGMTString()+"; path=/")
		}
		
		//得到上一个同一个div下的节点
		function getNextElement(node){    
			if(node.nextSibling.nodeType == 1){    //判断下一个节点类型为1则是“元素”节点   
				return node.nextSibling;    
			}    
			if(node.nextSibling.nodeType == 3){      //判断下一个节点类型为3则是“文本”节点  ，回调自身函数  
				return getNextElement(node.nextSibling);    
			}    
			return null;
		}
		//减号
		function butjian(elem){
			val=getNextElement(elem);
			if(val.value==1) return null;
			val.value--;
		}
		function getPreElement(node){    
			if(node.previousSibling.nodeType == 1){    //判断下一个节点类型为1则是“元素”节点   
				return node.previousSibling;    
			}    
			if(node.previousSibling.nodeType == 3){      //判断下一个节点类型为3则是“文本”节点  ，回调自身函数  
				return getPreElement(node.previousSibling);    
			}    
			return null;
		}
		//加号
		function butjia(elem){
			val=getPreElement(elem);
			val.value++;
		}
		
		function show(id){
			val=document.getElementById(id);
			val.style.display="block";
			//alert("显示");
		}
		function hidden(id){
			val=document.getElementById(id);
			val.style.display="none";
			//alert("隐藏");
		}
		//删除购物车里的信息
		function delgoodsofcar(elem){
			gid="g"+elem;
			vid="v"+elem;
			pid="p"+elem;
			good=document.getElementById(gid);
			gvalue=document.getElementById(vid);
			price=document.getElementById(pid);
			allnum=document.getElementById('allnum');//总数量
			allprice=document.getElementById("allprice");//总价
			
			badge=document.getElementById("badge");
			//alert(gvalue.value);
			badge.innerHTML=parseInt(badge.innerHTML)-parseInt(gvalue.value);
			allnum.innerHTML=badge.innerHTML;//总数量
			allprice.innerHTML=parseFloat(allprice.innerHTML)-parseFloat(price.value);//总价
			
			good.parentNode.removeChild(good);
			
			
			
			car=document.getElementById('goods');
			ss=car.innerHTML;
			setCookie('content',ss,1);//设置div内容
			setCookie('badge',badge.innerHTML,1);//设置badge
			setCookie('allprice',allprice.innerHTML,1);//设置总价
		}
		//添加购物车
		function addGoods(elem){		
			car=document.getElementById('goods');
			badge=document.getElementById("badge");
			allnum=document.getElementById('allnum');//总数量
			allprice=document.getElementById("allprice");//总价
			
			gname=getPreElement(elem);
			gprice=getPreElement(gname);
			gpath=getPreElement(gprice);
			gdanwei=getPreElement(gpath);
			gid=getPreElement(gdanwei);
			
			val=getPreElement(gid);
			val=getPreElement(val);
			val=getPreElement(val);
			
			ss=car.innerHTML;
			
			sprice=parseInt(val.value)*parseFloat(gprice.value);
			ss+="<div class='cargoods' id='g"+gid.value+"'>";
			ss+="<input type='hidden' name='num[]' id='v"+gid.value+"' value='"+val.value+"'>";//数量
			ss+="<input type='hidden' name='total[]' id='p"+gid.value+"' value='"+sprice+"'>";//总价
			ss+="<img src='/Green/Public/photo/"+gpath.value+"' width='50px' height='70px'>";
			ss+="<a href=\"javascript:delgoodsofcar('"+gid.value+"')\">X</a>";
			ss+="<div class='cp'>";
			ss+="<p>"+gname.value+"</p>"+gprice.value+"元/"+gdanwei.value+"</div>";
			ss+="<input type='hidden' name='gid[]' value='"+gid.value+"'>";//提交的数据
			ss+="<input type='hidden' name='gname[]' value='"+gname.value+"'>";//提交的数据
			ss+="<input type='hidden' name='price[]' value='"+gprice.value+"'>";//提交的数据
			ss+="<input type='hidden' name='danwei[]' value='"+gdanwei.value+"'>";//提交的数据
			ss+="<input type='hidden' name='path[]' value='"+gpath.value+"'>";//提交的数据
			ss+="<div class='sprice'><p>"+"数量:"+val.value+"</p>总价:"+sprice+"元</div>";
			ss+="</div>";
			
			//alert(ss);		
			car.innerHTML=ss;
			
			badge.innerHTML=parseInt(badge.innerHTML)+parseInt(val.value);			
			allnum.innerHTML=badge.innerHTML;//总数量
			allprice.innerHTML=parseFloat(allprice.innerHTML)+sprice;//总价
			
			setCookie('content',ss,1);//设置div内容
			setCookie('badge',badge.innerHTML,1);//设置badge
			setCookie('allprice',allprice.innerHTML,1);//设置总价
		}
				
	 </script>
</head>
<?php  function unescape($str) { $ret = ''; $len = strlen($str); for ($i = 0; $i < $len; $i ++) { if ($str[$i] == '%' && $str[$i + 1] == 'u') { $val = hexdec(substr($str, $i + 2, 4)); if ($val < 0x7f) $ret .= chr($val); else if ($val < 0x800) $ret .= chr(0xc0 | ($val >> 6)) . chr(0x80 | ($val & 0x3f)); else $ret .= chr(0xe0 | ($val >> 12)) . chr(0x80 | (($val >> 6) & 0x3f)) . chr(0x80 | ($val & 0x3f)); $i += 5; } else if ($str[$i] == '%') { $ret .= urldecode(substr($str, $i, 3)); $i += 2; } else $ret .= $str[$i]; } return $ret; } ?>
<body>

	 <style >
	   #mainbody{
			width:80%;
			margin-left:10%;
	   }
		#tright{
			float:left;
			margin-left:240px;
		}
		.p1{
			float:left;
			margin-left:0px;
			margin-top:24px;
		}
		.p2{
			float:left;
			margin-left:0px;
			margin-top:28px;
		}
		.p3{
			float:left;
			margin-left:0px;
			margin-top:22px;
		}
		#bottom{
			width:100%;
			margin-left:75%;
		}
		.address{
			width:100%;
			height:50px;
			line-height:50px;
			background-color:Gainsboro;
		}
		.loca{
			width:500px;
		}
		.btn{
			
		}
		#show{
			width:100%;
			border:1px solid grey;
			display:none;
		}
		#but-t{
			width:200px;
			height:50px;
			background-color:red;
		}
		#but-t:hover{
			background-color:green;
		}
     </style>
	 <script>
		//得到上一个同一个div下的节点
		function getNextElement(node){    
			if(node.nextSibling.nodeType == 1){    //判断下一个节点类型为1则是“元素”节点   
				return node.nextSibling;    
			}    
			if(node.nextSibling.nodeType == 3){      //判断下一个节点类型为3则是“文本”节点  ，回调自身函数  
				return getNextElement(node.nextSibling);    
			}    
			return null;
		}
		//减号
		function butjian(elem){
			val=getNextElement(elem);
			if(val.value==1) return null;
			val.value--;
			
			id=getPreElement(elem).value;
			tid="t"+id;
			pid="p"+id;
			total=document.getElementById(tid);
			price=document.getElementById(pid);
			//alert(parseFloat(price.innerHTML));
			total.innerHTML=parseInt(val.value)*parseFloat(price.innerHTML)+"元";
			
			gp=document.getElementById('goodpricies');//总金额
			alltotal=parseFloat(gp.innerHTML)-parseFloat(price.innerHTML);
			gp.innerHTML=alltotal+"元";
		}
		function getPreElement(node){    
			if(node.previousSibling.nodeType == 1){    //判断下一个节点类型为1则是“元素”节点   
				return node.previousSibling;    
			}    
			if(node.previousSibling.nodeType == 3){      //判断下一个节点类型为3则是“文本”节点  ，回调自身函数  
				return getPreElement(node.previousSibling);    
			}    
			return null;
		}
		//加号
		function butjia(elem){
			val=getPreElement(elem);
			val.value++;
			
			id=getNextElement(elem).value;
			tid="t"+id;
			pid="p"+id;
			total=document.getElementById(tid);
			price=document.getElementById(pid);
			//alert(parseFloat(price.innerHTML));
			total.innerHTML=parseInt(val.value)*parseFloat(price.innerHTML)+"元";
			
			
			
			gp=document.getElementById('goodpricies');//总金额
			alltotal=parseFloat(gp.innerHTML)+parseFloat(price.innerHTML);
			//alert(parseFloat(gp.innerHTML));
			gp.innerHTML=alltotal+"元";
		}
		//显示新地址
		function show(elem){
			val=document.getElementById(elem);
			val.style.display="block";
		}
		
		function hid(elem){
			//alert("123");
			val=document.getElementById(elem);
			val.style.display="none";
		}
	 </script>
<!--头部-->
<div id="top">
	<span id="tleft">
		<img src="/Green/Public/assest/image/shoplogo.jpg" width="300px">	
	</span>
	<span id="tright" align="center">
		<div class="p1"><img src="/Green/Public/assest/image/icon/05.png" width="80px"><p>我的购物车</p></div>
		<div class="p2"><img src="/Green/Public/assest/image/icon/06.png" width="100px"><p>确认订单</p></div>
		<div class="p2"><img src="/Green/Public/assest/image/icon/06.png" width="100px"><p>成功提交订单</p></div>
		<div class="p3"><img src="/Green/Public/assest/image/icon/04.png" width="80px"><p>付款成功</p></div>
	</span>
<hr width="100%" style="margin-top:-5px;border:2px solid white;">
<hr width="100%" style="margin-top:-5px;border:2px solid green;">
</div>

<div id="mainbody">
	<table class="table">
	<tr><th>商品名称</th><th>规格</th><th>价格</th><th>数量</th><th>金额</th></tr>
	<?php if(is_array($list)): $i = 0; $__LIST__ = $list;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i; $picpath=str_replace("thumb_","",$vo['pic']); ?>
	<tr>
	<td><a href="<?php echo U('List/showgood',array('id'=>$vo[gid]));?>"><img src='/Green/Public/photo/<?php echo ($picpath); ?>' 
	width="80px"><?php echo ($vo["gname"]); ?></a></td>
	<td><?php echo ($vo["danwei"]); ?>/份</td>
	<td><p id="p<?php echo ($vo["gid"]); ?>"><?php echo ($vo["price"]); ?>元</p></td>
	<td><p><?php echo ($vo["num"]); ?></p></td>
	<td><p id="t<?php echo ($vo["gid"]); ?>"><?php echo ($vo["total"]); ?>元</p></td>
	</tr><?php endforeach; endif; else: echo "" ;endif; ?>
	</table>
	<hr>
	<?php if(is_array($dingdan)): $i = 0; $__LIST__ = $dingdan;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?><div class="address">
		收货地址:<?php echo ($vo["receiver"]); ?>&nbsp(<?php echo ($vo["address"]); ?>)&nbsp<?php echo ($vo["phone"]); ?>
		</div>
		<hr><?php endforeach; endif; else: echo "" ;endif; ?>
	<div id="bottom">
		商品金额<p id="goodpricies"><?php echo ($_SESSION['user']['dingdan']['total']); ?>元</p>
		<form action="<?php echo U('Pay/finish');?>">
		<input type="submit" class="btn-primary" value="提交订单">
		</form>
	</div>
</div>
<hr>
    <!-- Footer -->
    <footer>
        <div class="container">
            <div class="row">
                <div class="col-lg-12" align="center">
                    <p class="copyright text-muted small">Copyright 2016-2017 | <a href="/Green/admin.php/Login/login">Yangjianli</a> All Rights Reserved<br>站长邮箱:574153393@qq.com</p>
                </div>	
            </div>
        </div>
    </footer>

</body>

</html>